ED2 KC- Process failed: StatementCallback; bad SQL grammar [create table ....


Causes

Sometimes it is a bad SQL View (DHIS2 type). Others it is when some piece of metadata is out of place or can’t be found - Common amongst OUs, Category-related metadata (e.g. having quotes in category names), and periods.

Resolution

  1. Regenerate Resource Tables and Analytics

If that doesn’t work:

2. Clear Analytics (data admin > maintenance), and clear cache.

3. Check SQL views or categories if the error points to one , as opposed to analytics tables.

4. Run Analytics and Resource tables again.

Examples:

Bad SQL Grammar causing org unit filter to fail on dashboards.

Query failed, likely because the requested analytics table does not exist (AbstractJdbcEventAnalyticsManager.java [http-nio2-8081-exec-62])
org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [select count(psi) as value,'20200313' as Daily from analytics_event_pnclhazartz as ax ....

Resolution Example

To avoid this situtation in the future, when you change any metadata that is used in the filter, you must must regenerate the resource and analytic tables prior to looking at the dashboard. This is because  the analytics tables need to be able to account for the added dimensions that have been added. This step should be completed after the changes have been deployed to your data and can be triggered via the data maintenance app. 

Thank you,